import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/home",
  },
  {
    path: "/home",
    component: Home,
    redirect: "/home/shop",
    children: [
      {
        path: "shop",
        name: "shop",
        meta: {
          info: 1,
        },
        component: () => import("@/views/home/shop/Shop.vue"),
      },
      {
        path: "classify",
        name: "classify",
        component: () => import("@/views/home/classify/Classify.vue"),
      },
      {
        path: "shoppingcart",
        name: "shoppingcart",
        component: () => import("@/views/home/shoppingcart/ShoppingCart.vue"),
      },
      {
        path: "login",
        name: "login",
        component: () => import("@/views/home/login/Login.vue"),
      },
      {
        path: "shopsearch",
        name: "shopsearch",
        component: () => import("@/views/home/shopsearch/ShopSearch.vue"),
      },
      {
        path: "SearchResult/:val",
        name: "SearchResult",
        component: () => import("@/views/home/shopsearch/SearchResult.vue"),
      },
    ],
  },
  {
    path: "/videoproductdetails/:itemId/:actorId/:videoUrl",
    name: "videoproductdetails",
    component: () =>
      import("@/views/videoproductdetails/VideoProductDetails.vue"),
  },
  {
    path: "/productdetails/:tradeItemId",
    name: "productdetails",
    component: () => import("@/views/productdetails/Productdetails.vue"),
  },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
